From 2311c39dddf55b72bbb2cbdedd7085b78cee9dcf Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 31 Dec 2007 21:19:44 +0000 Subject: [PATCH] If successive points aren't > 50 meters apart in KML realtime tracking, don't count the point. --- kml.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/kml.c b/kml.c index 6584de125..aa8a79004 100644 --- a/kml.c +++ b/kml.c @@ -21,6 +21,7 @@ */ #include "defs.h" #include "xmlgeneric.h" +#include "grtcirc.h" #ifdef __WIN32__ # include @@ -852,6 +853,16 @@ static void kml_waypt_pr(const waypoint *waypointp) { const char *icon; +#if 0 // Experimental + if(realtime_positioning) { + kml_write_xml(1, "\n"); + kml_write_xml(0, "%f\n", waypointp->longitude); + kml_write_xml(0, "%f\n", waypointp->latitude); + kml_write_xml(0, "1000\n"); + kml_write_xml(-1, "\n"); + } +#endif + if (waypointp->gc_data.diff && waypointp->gc_data.terr) { kml_geocache_pr(waypointp); return; @@ -1117,7 +1128,25 @@ kml_wr_position(waypoint *wpt) wpt->icon_descr = kml_get_posn_icon(wpt->creation_time - last_valid_fix); - track_add_wpt(posn_trk_head, waypt_dupe(wpt)); + + /* In order to avoid clutter while we're sitting still, don't add + track points if we've not moved a minimum distance from the + beginnning of our accumulated track. */ + { + waypoint *newest_posn= (waypoint *) QUEUE_LAST(&posn_trk_head->waypoint_list); + + if(radtometers(gcdist(RAD(wpt->latitude), RAD(wpt->longitude), + RAD(newest_posn->latitude), RAD(newest_posn->longitude))) > 50) { + track_add_wpt(posn_trk_head, waypt_dupe(wpt)); + } else { + /* If we haven't move more than our threshold, pretend + * we didn't move at all to prevent Earth from jittering + * the zoom levels on us. + */ + wpt->latitude = newest_posn->latitude; + wpt->longitude = newest_posn->longitude; + } + } waypt_add(wpt); kml_write(); -- 2.30.2